/**
 * @Title: RegExpUtils
 * @Package cn.com.yiqi.wsc.util
 * @Description: TODO
 * Copyright: Copyright (c) 2016
 * Company: 成都壹柒互动科技有限公司
 * @author 会员系统组-胥钰淋
 * @date 2017/3/2 17:52
 * @version V1.0
 */
package cn.com.yiqi.wsc.util;

import org.apache.commons.lang3.StringUtils;

/**
 *
 *@ClassName: RegExpUtils
 * @Description: TODO
 * @author 会员系统组-胥钰淋
 * @date 2017/3/2 17:52
 *
 */
public class RegExpUtils {

    private static final String EMAIL = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";

    private static final String CHINESE_PHONE = "(^(13\\d|15[^4,\\D]|17[13678]|18\\d)\\d{8}|170[^346,\\D]\\d{7})$";
    private static final String DIAN_XIN_PHONE = "^1(33|53|8[019]|7[73])\\d{8}$";

    /**
     * 验证邮箱地址
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        if (StringUtils.isNotEmpty(email)) {
            return email.matches(EMAIL);
        } else {
            return false;
        }
    }

    /**
     * 验证中国大陆手机号
     * @param phone
     * @return
     */
    public static boolean isChinesePhone(String phone) {
        if (StringUtils.isNotEmpty(phone)) {
            return phone.matches(CHINESE_PHONE);
        } else {
            return false;
        }
    }

    /**
     * 验证电信手机号
     * @param phone
     * @return
     */
    public static boolean isDianXinPhone(String phone) {
        if (StringUtils.isNotEmpty(phone)) {
            return phone.matches(DIAN_XIN_PHONE);
        } else {
            return false;
        }
    }

    public static void main(String[] args) {

        System.out.println(isEmail("sdsdsd@qq.com"));

        System.out.println(isChinesePhone("18911111111"));
    }

}
